package atm.computing;

import java.util.ArrayList;
import java.util.List;
import java.util.SortedMap;
import java.util.TreeMap;

public class Factorizator {
	public int[] expensiveFactorize(int number) {
		List<Integer> fact = new ArrayList<>();

		int prime = 2;
		while (number > 1) {
			if (number > 1 && number % prime == 0) {
				number /= prime;
				fact.add(prime);
			} else {
				prime++;
				while (!isPrime(prime)) {
					prime++;
				}
			}
		}

		int[] result;
		result = DKUtil.makeIntArray(fact);

		return result;
	}

	private boolean isPrime(int number) {
		for (int divisor = 2; divisor < number; divisor++) {
			if (number % divisor == 0) {
				return false;
			}
		}
		return true;
	}
}
